package com.happy.code.gui;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;

import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;

/**
 * @类说明：
 * 
 * @author YANGJIE
 * @version 1.0
 * @创建时间：2016年8月6日 下午4:48:15
 */
public class Start {
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Start().run();
			}
		});
	}
	
	public void run() {
		try {
			// 设置本属性将改变窗口边框样式定义
			System.setProperty("sun.java2d.noddraw", "true");
			BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.translucencySmallShadow;
			BeautyEyeLNFHelper.launchBeautyEyeLNF();
			UIManager.put("RootPane.setupButtonVisible", false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		JFrame jf = new JFrame("小工具");
		JMenuBar menuBar = new JMenuBar();
		JMenu menu = new JMenu("设置");
		JMenu aboutMenu = new JMenu("关于");
		JMenuItem databaseItem = new JMenuItem("数据库配置");
		databaseItem.addActionListener(new ShowActionListener());
		databaseItem.setName("databaseSet");
		menu.add(databaseItem);

		JMenuItem aboutItem = new JMenuItem("关于");
		aboutItem.setName("aboutItem");
		aboutMenu.add(aboutItem);

		// databaseItem.addActionListener(new ShowActionListener());
		// loadDbItem.addActionListener(new ShowActionListener());
		// aboutItem.addActionListener(new ShowActionListener());

		menuBar.add(menu);
		menuBar.add(aboutMenu);

		jf.setJMenuBar(menuBar);
		jf.setSize(800, 600);
		jf.setLocationRelativeTo(null);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setContentPane(new MainPanel());
		// jf.setContentPane(new ConfigPanel());
		jf.setVisible(true);
	}
	
	/**
	 * 数据库配置界面
	 */
	private class ShowActionListener implements ActionListener {
        public void actionPerformed(ActionEvent actionEvent) {
            String name = actionEvent.getActionCommand();
            if (name.equals("数据库配置")) {
                JDialog jd = new JDialog();
                jd.setModal(true);
                jd.setSize(800, 800);
                jd.setLocationRelativeTo(null);
                jd.setContentPane(new ConfigPanel());
                jd.setVisible(true);
            }
        }
    }
}
